package com.imooc.oa.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//实现注销功能
@WebServlet(name = "LogoutServlet",urlPatterns = "/logout")
public class LogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //清除session中的当前登录的用户、员工、部门信息
        request.getSession().invalidate();//直接将当前的会话彻底清除掉，更常用简单
        //也可挨个清除会话中的属性，但麻烦
//        request.getSession().removeAttribute("login_user");
//        request.getSession().removeAttribute("current_employee");
//        request.getSession().removeAttribute("current_department");
        response.sendRedirect("/login.html");


    }
}
